<template>
  <div class="body">
    <div class="container">
      <div class="top"></div>
      <div class="bottom"></div>
      <div class="center">
        <h2 class="header-active">
          <div :class="[active ? 'active' : 'is_cursor']" @click="header_active_click">登录</div>/
          <div :class="[active ? 'is_cursor' : 'active']" @click="header_active_click">注册</div>
        </h2>
        <div :class="[active ? 'is-block' : 'is-none']">
          <Login></Login>
        </div>

        <div :class="[active ? 'is-none' : 'is-block']">
          <Register></Register>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import Login from '@/components/Login.vue'
import Register from '@/components/Register.vue'

const active = ref<boolean>(true);
const header_active_click = () => {
  if (active.value === true) {
    active.value = false
  } else {
    active.value = true
  }
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.body {
  position: relative;
  height: 100vh;
}

.container {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.top:before,
.top:after,
.bottom:before,
.bottom:after {
  content: "";
  position: absolute;
  width: 200vw;
  height: 200vw;
  top: 50%;
  left: 50%;
  margin-top: -100vw;
  transform-origin: 0 50%;
  transition: all 0.5s cubic-bezier(0.445, 0.05, 0, 1);
  z-index: 10;
  opacity: 0.65;
  transition-delay: 0.2s;
}

.top:before {
  transform: rotate(45deg);
  background: #e46569;
}

.top:after {
  transform: rotate(135deg);
  background: #ecaf81;
}

.bottom:before {
  transform: rotate(-45deg);
  background: #60b8d4;
}

.bottom:after {
  transform: rotate(-135deg);
  background: #3745b5;
}

.center {
  position: absolute;
  width: 400px;
  height: 400px;
  top: 50%;
  left: 50%;
  margin-left: -200px;
  margin-top: -200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.445, 0.05, 0, 1);
  transition-delay: 0s;
  color: #333;
}

.container:hover .top:before,
.container:hover .top:after,
.container:hover .bottom:before,
.container:hover .bottom:after,
.container:active .top:before,
.container:active .top:after,
.container:active .bottom:before,
.container:active .bottom:after {
  margin-left: 200px;
  transform-origin: -200px 50%;
  transition-delay: 0s;
}

.container:hover .center,
.container:active .center {
  opacity: 1;
  transition-delay: 0.2s;
}

.active {
  color: #e46569;
  cursor: default;
  pointer-events: none;
}

.header-active {
  display: flex;
}

.is_cursor {
  cursor: pointer;
}

.is-block {
  display: block;
}

.is-none {
  display: none;
}
</style>